//
//  WebViewController.m
//  eNew
//
//  Created by lanou3g on 15-4-29.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "WebViewController.h"
#import "ButtonView.h"
#import "ShareSDK/ShareSDK.h"
@interface WebViewController ()

@property (nonatomic, retain) UIWebView *webView;
@property (nonatomic, retain) ButtonView *buttonView;

@end

@implementation WebViewController

- (void)viewDidLoad {
    self.webView = [[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 375, 618)] autorelease];
    NSURL *url = [NSURL URLWithString:_url];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [_webView loadRequest:request];
    [self.view addSubview:_webView];
    
    self.buttonView = [[[ButtonView alloc] initWithFrame:CGRectMake(0, 618, 375, 49)] autorelease];
    [self.view addSubview:_buttonView];
    

    // 给button添加事件
    [self.buttonView.shareButton addTarget:self action:@selector(shareButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttonView.collectButton addTarget:self action:@selector(collectButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttonView.blackButton addTarget:self action:@selector(blackButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttonView.reportButton addTarget:self action:@selector(reportButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}

#pragma mark 实现button方法
- (void)shareButtonAction:(UIButton *)sender {
    
    NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"ShareSDK" ofType:@"png"];
    
    
    // 构造分享内容
    id<ISSContent> publishContent = [ShareSDK content:@"分享内容"
                                       defaultContent:@"测试一下"
                                                image:[ShareSDK imageWithPath:imagePath]
                                                title:@"ShareSDK"
                                                  url:@"http://www.mob.com"
                                          description:@"这是一条测试信息"
                                            mediaType:SSPublishContentMediaTypeNews];
    
    
    // 创建弹出菜单容器
    id<ISSContainer> container = [ShareSDK container];
    
    [container setIPadContainerWithView:sender arrowDirect:UIPopoverArrowDirectionUp];
    
    
    //弹出分享菜单
    [ShareSDK showShareActionSheet:container shareList:nil content:publishContent statusBarTips:YES authOptions:nil
     
                      shareOptions:nil result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo>
                                                
                                                statusInfo, id<ICMErrorInfo> error, BOOL end) {
                          
                          if (state == SSResponseStateSuccess) {
                              
                              NSLog(NSLocalizedString (@"TEXT_SHARE_SUC", @"分享成功"));
                              
                          } else if (state == SSResponseStateFail) {
                              
                              NSLog(NSLocalizedString(@"TEXT_SHARE_FAI", @"分享失败，错误码：%d, 错误描述：%@"), [error errorCode], [error errorDescription]);
                          }
                      }];
}

- (void)collectButtonAction:(UIButton *)sender {
    
}

- (void)blackButtonAction:(UIButton *)sender {
    
}

- (void)reportButtonAction:(UIButton *)sender {
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


#pragma mark 重写dealloc
- (void)dealloc
{
    [_webView release];
    [super dealloc];
   
}


@end
